import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
import { SurveyQuestionEntity } from '@src/modules/Survey/entities/SurveyQuestion.entity';

@Entity('survey')
export class SurveyEntity {

  @PrimaryGeneratedColumn()
  id: string;

  @Column({ length: 255, comment: '问卷标题' })
  surveyName: string;

  @Column({ length: 255, comment: '副标题' })
  surveySubtitle: string;

  @Column({
    type: 'timestamp',
    nullable: false,
    comment: '创建时间',
  })
  createdAt: Date;

  @Column({
    type: 'timestamp',
    nullable: false,
    comment: '修改时间',
  })
  updatedAt: Date;

  // 提交总人数
  totalSubmissions: number;

  @OneToMany(() => SurveyQuestionEntity, surveyQuestion => surveyQuestion.survey)
  questions: SurveyQuestionEntity[];
}
